home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libregsub.tex < prev    next >
LaTeX Document  |  1994-01-02  |  1.3 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libregsub.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 53 74 61 6e 64 61 72 |\section|{Standar|
|00000010| 64 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |d Module| \sectco|
|00000020| 64 65 7b 72 65 67 73 75 | 62 7d 7d 0d 0d 5c 73 74 |de{regsu|b}}..\st|
|00000030| 6d 6f 64 69 6e 64 65 78 | 7b 72 65 67 73 75 62 7d |modindex|{regsub}|
|00000040| 0d 54 68 69 73 20 6d 6f | 64 75 6c 65 20 64 65 66 |.This mo|dule def|
|00000050| 69 6e 65 73 20 61 20 6e | 75 6d 62 65 72 20 6f 66 |ines a n|umber of|
|00000060| 20 66 75 6e 63 74 69 6f | 6e 73 20 75 73 65 66 75 | functio|ns usefu|
|00000070| 6c 20 66 6f 72 20 77 6f | 72 6b 69 6e 67 20 77 69 |l for wo|rking wi|
|00000080| 74 68 0d 72 65 67 75 6c | 61 72 20 65 78 70 72 65 |th.regul|ar expre|
|00000090| 73 73 69 6f 6e 73 20 28 | 73 65 65 20 62 75 69 6c |ssions (|see buil|
|000000a0| 74 2d 69 6e 20 6d 6f 64 | 75 6c 65 20 5c 63 6f 64 |t-in mod|ule \cod|
|000000b0| 65 7b 72 65 67 65 78 7d | 29 2e 0d 0d 5c 72 65 6e |e{regex}|)...\ren|
|000000c0| 65 77 63 6f 6d 6d 61 6e | 64 7b 5c 69 6e 64 65 78 |ewcomman|d{\index|
|000000d0| 73 75 62 69 74 65 6d 7d | 7b 28 69 6e 20 6d 6f 64 |subitem}|{(in mod|
|000000e0| 75 6c 65 20 72 65 67 73 | 75 62 29 7d 0d 5c 62 65 |ule regs|ub)}.\be|
|000000f0| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 73 75 |gin{func|desc}{su|
|00000100| 62 7d 7b 70 61 74 5c 2c | 20 72 65 70 6c 5c 2c 20 |b}{pat\,| repl\, |
|00000110| 73 74 72 7d 0d 52 65 70 | 6c 61 63 65 20 74 68 65 |str}.Rep|lace the|
|00000120| 20 66 69 72 73 74 20 6f | 63 63 75 72 72 65 6e 63 | first o|ccurrenc|
|00000130| 65 20 6f 66 20 70 61 74 | 74 65 72 6e 20 5c 76 61 |e of pat|tern \va|
|00000140| 72 7b 70 61 74 7d 20 69 | 6e 20 73 74 72 69 6e 67 |r{pat} i|n string|
|00000150| 0d 5c 76 61 72 7b 73 74 | 72 7d 20 62 79 20 72 65 |.\var{st|r} by re|
|00000160| 70 6c 61 63 65 6d 65 6e | 74 20 5c 76 61 72 7b 72 |placemen|t \var{r|
|00000170| 65 70 6c 7d 2e 20 20 49 | 66 20 74 68 65 20 70 61 |epl}. I|f the pa|
|00000180| 74 74 65 72 6e 20 69 73 | 6e 27 74 20 66 6f 75 6e |ttern is|n't foun|
|00000190| 64 2c 0d 74 68 65 20 73 | 74 72 69 6e 67 20 69 73 |d,.the s|tring is|
|000001a0| 20 72 65 74 75 72 6e 65 | 64 20 75 6e 63 68 61 6e | returne|d unchan|
|000001b0| 67 65 64 2e 20 20 54 68 | 65 20 70 61 74 74 65 72 |ged. Th|e patter|
|000001c0| 6e 20 6d 61 79 20 62 65 | 20 61 20 73 74 72 69 6e |n may be| a strin|
|000001d0| 67 20 6f 72 20 61 6e 0d | 61 6c 72 65 61 64 79 20 |g or an.|already |
|000001e0| 63 6f 6d 70 69 6c 65 64 | 20 70 61 74 74 65 72 6e |compiled| pattern|
|000001f0| 2e 20 20 54 68 65 20 72 | 65 70 6c 61 63 65 6d 65 |. The r|eplaceme|
|00000200| 6e 74 20 6d 61 79 20 63 | 6f 6e 74 61 69 6e 20 72 |nt may c|ontain r|
|00000210| 65 66 65 72 65 6e 63 65 | 73 0d 5c 73 61 6d 70 7b |eference|s.\samp{|
|00000220| 5c 65 20 5c 76 61 72 7b | 64 69 67 69 74 7d 7d 20 |\e \var{|digit}} |
|00000230| 74 6f 20 73 75 62 70 61 | 74 74 65 72 6e 73 20 61 |to subpa|tterns a|
|00000240| 6e 64 20 65 73 63 61 70 | 65 64 20 62 61 63 6b 73 |nd escap|ed backs|
|00000250| 6c 61 73 68 65 73 2e 0d | 5c 65 6e 64 7b 66 75 6e |lashes..|\end{fun|
|00000260| 63 64 65 73 63 7d 0d 0d | 5c 62 65 67 69 6e 7b 66 |cdesc}..|\begin{f|
|00000270| 75 6e 63 64 65 73 63 7d | 7b 67 73 75 62 7d 7b 70 |uncdesc}|{gsub}{p|
|00000280| 61 74 5c 2c 20 72 65 70 | 6c 5c 2c 20 73 74 72 7d |at\, rep|l\, str}|
|00000290| 0d 52 65 70 6c 61 63 65 | 20 61 6c 6c 20 28 6e 6f |.Replace| all (no|
|000002a0| 6e 2d 6f 76 65 72 6c 61 | 70 70 69 6e 67 29 20 6f |n-overla|pping) o|
|000002b0| 63 63 75 72 72 65 6e 63 | 65 73 20 6f 66 20 70 61 |ccurrenc|es of pa|
|000002c0| 74 74 65 72 6e 20 5c 76 | 61 72 7b 70 61 74 7d 20 |ttern \v|ar{pat} |
|000002d0| 69 6e 0d 73 74 72 69 6e | 67 20 5c 76 61 72 7b 73 |in.strin|g \var{s|
|000002e0| 74 72 7d 20 62 79 20 72 | 65 70 6c 61 63 65 6d 65 |tr} by r|eplaceme|
|000002f0| 6e 74 20 5c 76 61 72 7b | 72 65 70 6c 7d 2e 20 20 |nt \var{|repl}. |
|00000300| 54 68 65 20 73 61 6d 65 | 20 72 75 6c 65 73 20 61 |The same| rules a|
|00000310| 73 20 66 6f 72 0d 5c 63 | 6f 64 65 7b 73 75 62 28 |s for.\c|ode{sub(|
|00000320| 29 7d 20 61 70 70 6c 79 | 2e 20 20 45 6d 70 74 79 |)} apply|. Empty|
|00000330| 20 6d 61 74 63 68 65 73 | 20 66 6f 72 20 74 68 65 | matches| for the|
|00000340| 20 70 61 74 74 65 72 6e | 20 61 72 65 20 72 65 70 | pattern| are rep|
|00000350| 6c 61 63 65 64 20 6f 6e | 6c 79 0d 77 68 65 6e 20 |laced on|ly.when |
|00000360| 6e 6f 74 20 61 64 6a 61 | 63 65 6e 74 20 74 6f 20 |not adja|cent to |
|00000370| 61 20 70 72 65 76 69 6f | 75 73 20 6d 61 74 63 68 |a previo|us match|
|00000380| 2c 20 73 6f 20 65 2e 67 | 2e 0d 5c 63 6f 64 65 7b |, so e.g|..\code{|
|00000390| 67 73 75 62 28 27 27 2c | 20 27 2d 27 2c 20 27 61 |gsub('',| '-', 'a|
|000003a0| 62 63 27 29 7d 20 72 65 | 74 75 72 6e 73 20 5c 63 |bc')} re|turns \c|
|000003b0| 6f 64 65 7b 27 2d 61 2d | 62 2d 63 2d 27 7d 2e 0d |ode{'-a-|b-c-'}..|
|000003c0| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|000003d0| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|000003e0| 7b 73 70 6c 69 74 7d 7b | 73 74 72 5c 2c 20 70 61 |{split}{|str\, pa|
|000003f0| 74 7d 0d 53 70 6c 69 74 | 20 74 68 65 20 73 74 72 |t}.Split| the str|
|00000400| 69 6e 67 20 5c 76 61 72 | 7b 73 74 72 7d 20 69 6e |ing \var|{str} in|
|00000410| 20 66 69 65 6c 64 73 20 | 73 65 70 61 72 61 74 65 | fields |separate|
|00000420| 64 20 62 79 20 64 65 6c | 69 6d 69 74 65 72 73 20 |d by del|imiters |
|00000430| 6d 61 74 63 68 69 6e 67 | 0d 74 68 65 20 70 61 74 |matching|.the pat|
|00000440| 74 65 72 6e 20 5c 76 61 | 72 7b 70 61 74 7d 2c 20 |tern \va|r{pat}, |
|00000450| 61 6e 64 20 72 65 74 75 | 72 6e 20 61 20 6c 69 73 |and retu|rn a lis|
|00000460| 74 20 63 6f 6e 74 61 69 | 6e 69 6e 67 20 74 68 65 |t contai|ning the|
|00000470| 20 66 69 65 6c 64 73 2e | 20 20 4f 6e 6c 79 0d 6e | fields.| Only.n|
|00000480| 6f 6e 2d 65 6d 70 74 79 | 20 6d 61 74 63 68 65 73 |on-empty| matches|
|00000490| 20 66 6f 72 20 74 68 65 | 20 70 61 74 74 65 72 6e | for the| pattern|
|000004a0| 20 61 72 65 20 63 6f 6e | 73 69 64 65 72 65 64 2c | are con|sidered,|
|000004b0| 20 73 6f 20 65 2e 67 2e | 0d 5c 63 6f 64 65 7b 73 | so e.g.|.\code{s|
|000004c0| 70 6c 69 74 28 27 61 3a | 62 27 2c 20 27 3a 2a 27 |plit('a:|b', ':*'|
|000004d0| 29 7d 20 72 65 74 75 72 | 6e 73 20 5c 63 6f 64 65 |)} retur|ns \code|
|000004e0| 7b 5b 27 61 27 2c 20 27 | 62 27 5d 7d 20 61 6e 64 |{['a', '|b']} and|
|000004f0| 0d 5c 63 6f 64 65 7b 73 | 70 6c 69 74 28 27 61 62 |.\code{s|plit('ab|
|00000500| 63 27 2c 20 27 27 29 7d | 20 72 65 74 75 72 6e 73 |c', '')}| returns|
|00000510| 20 5c 63 6f 64 65 7b 5b | 27 61 62 63 27 5d 7d 2e | \code{[|'abc']}.|
|00000520| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
+--------+-------------------------+-------------------------+--------+--------+